﻿namespace ManagerClinic.Core.DataAccess
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using ManagerClinic.Core.Common;
    using System.Data.Common;
    using System.Data;
    using Microsoft.Practices.EnterpriseLibrary.Data;
    using Microsoft.Practices.EnterpriseLibrary.Common;
    using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
    using ManagerClinic.Ultilities.Ultility;

    public  class ThietLapMaDataAccess
    {
        public string GetThietLapMa(string tableName)
        {
            try
            {
               
                string sql = "spThietLapMa_Select";
                string Ma = "";
                Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>();
                DbCommand cmd = db.GetStoredProcCommand(sql);
                db.AddInParameter(cmd, "tablename", DbType.String, tableName);
                using (IDataReader reader = db.ExecuteReader(cmd))
                {
                    while (reader.Read())
                    {
                        Ma = reader[0].ToString();
                    }
                }
                return Ma;
            }
            catch (Exception ex) { LogExceptionUltilities.LogException("GetThietLapMa", ex.Message); throw ex; }
        }
    }
}
